package seiacpsjava.sortalgorithms;

import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;

public class SelectionSortTestCase {
	
	private SortAlgorithm sortAlgorithm;
	
	@Before
	public void setup() {
		this.sortAlgorithm = SortAlgorithmFactory.getSelectionSortAlgorithm();
	}
	
	
	@Test
	public void testSortWithEmptyArray() {
		
		int [] items = {};
		
		sortAlgorithm.sort(items);
		assertEquals(items.length, 0);
	}
	
	@Test
	public void testSortwithOneItem() {
		
		int [] items = {5};
		
		sortAlgorithm.sort(items);
		assertEquals(items[0], 5);
		
	}
	
	@Test
	public void testSortwithTwoItems() {
		
		int [] items = {5,1};
		
		sortAlgorithm.sort(items);
		assertEquals(items[0], 1);
		assertEquals(items[1], 5);
	}
	
	@Test
	public void testSort() {
		
		int [] items = { 5, 1, 4, 2, 8};
		
		sortAlgorithm.sort(items);
		
		assertEquals(items[0], 1);
		assertEquals(items[1], 2);
		assertEquals(items[2], 4);
		assertEquals(items[3], 5);
		assertEquals(items[4], 8);
	}
}
